<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="./js/vue.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="app">
        <h2>{{num}}</h2>
        <h2 v-html="ht" v-bind:data-title="title"></h2>
        <button @click="addnum">改变num</button>
        <h2 v-text="text"></h2>
        <h2>{{revertext}}</h2>
        <h2>{{newtext()}}</h2>
        <input type="text" v-model="text">

    </div>
</body>
<script>
    const vm = new Vue({
        el: "#app",
        data: {
            title: "模板语法 - 计算属性 - watch",
            text: "WH2116 - Work Hard for offer ",
            num: 2022,
            ht: "<h2>这是一个html超文本</h2>"
        },
        computed: {
            revertext() {
                return this.text.split("").reverse().join("") + ' ' + new Date().getSeconds();
            }
        },
        methods: {
            newtext() {
                return this.text.split("").reverse().join("") + ' ' + new Date().getSeconds();
            },
            addnum() {
                this.num++
            }
        }
    })
</script>

</html>